<template>
	<view class="parameter">
		<view class="cell" v-if="info.platformName">
			<view class="label">接单平台</view>
			<view class="value">{{ info.platformName }}</view>
		</view>
		<view class="cell" v-if="info.level">
			<view class="label">车辆级别</view>
			<view class="value">{{ info.level }}</view>
		</view>
		<view class="cell" v-if="info.years">
			<view class="label">年限</view>
			<view class="value">{{ info.years }}</view>
		</view>
		<view class="cell" v-if="info.powerType">
			<view class="label">动力类型</view>
			<view class="value">{{ info.powerType }}</view>
		</view>
		<view class="cell" v-if="info.gearbox">
			<view class="label">变速箱</view>
			<view class="value">{{ info.gearbox }}</view>
		</view>
		<view class="cell" v-if="info.batteryType">
			<view class="label">电池类型</view>
			<view class="value">{{ info.batteryType }}</view>
		</view>
		<view class="cell" v-if="info.batteryFactory">
			<view class="label">电池厂家</view>
			<view class="value">{{ info.batteryFactory }}</view>
		</view>
		<view class="cell" v-if="info.chargingMode">
			<view class="label">充电模式</view>
			<view class="value">{{ info.chargingMode }}</view>
		</view>
		<view class="cell" v-if="info.wheelBase">
			<view class="label">轴距</view>
			<view class="value">{{ info.wheelBase }}</view>
		</view>
		<view class="cell" v-if="info.nature">
			<view class="label">车辆性质</view>
			<view class="value">{{ info.nature }}</view>
		</view>
		<view class="cell" v-if="info.fineness">
			<view class="label">成色</view>
			<view class="value">{{ info.fineness }}</view>
		</view>
		<view class="cell" v-if="info.continueMileage">
			<view class="label">里程</view>
			<view class="value">{{ info.continueMileage }}</view>
		</view>
		<view class="cell" v-if="info.seating">
			<view class="label">座位数</view>
			<view class="value">{{ info.seating }}</view>
		</view>
		<view class="cell" v-if="info.colors">
			<view class="label">外观颜色</view>
			<view class="value">{{ info.colors }}</view>
		</view>
		<view class="cell" v-if="info.emission">
			<view class="label">排放标准</view>
			<view class="value">{{ info.emission }}</view>
		</view>
		<view class="cell" v-if="info.configure && info.configure.length > 0">
			<view class="label">亮点配置</view>
			<view class="value">{{ info.configure ? info.configure.toString() : '' }}</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad,
		onPageScroll
	} from "@dcloudio/uni-app";
	import {
		doDetail
	} from '@/apis/car.js'

	const info = ref({
		strength: {},
		slideshow: [],
		schemes: [],
		detailsImg: [],
		configure: []
	})
	const init = async (id) => {
		const data = await doDetail(id)
		data.platform = JSON.parse(data.platform)
		data.platformName = uni.$uv.deepClone(data.platform).map(el => {
			return el.name
		}).toString()
		data.schemes = JSON.parse(data.schemes)
		data.strength = JSON.parse(data.strength)
		info.value = data
		console.log(data)
	}
	onLoad((e) => {
		init(e.id)
	})
</script>

<style lang="scss" scoped>
	.parameter {
		padding: 24rpx;

		.cell {
			display: flex;

			&:not(:first-child) {
				margin-top: 30rpx;
			}

			.label {
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
			}

			.value {
				margin-left: 40rpx;
				flex: 1;
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				text-align: right;
			}
		}
	}
</style>